//*******************************************************************
//  CommunityChestDeck.java       Authors: Jason M. Campbell
//										   Randall Brunson
//
//  Object that contains a list or "deck" of Community Chest cards
//  for the Monopoly game.  An array of Strings containing image
//  names will correspond to the actual .jpg images of the same name.
//*******************************************************************

import java.util.*;

public class CommunityChestDeck
{
	// array to hold Community Chest card names
	private ArrayList<String> commchestArrayList;
	
	// array containing actual names of the Community Chance card images
	// (minus the .jpg extension)
	private String[] commchestStringArray = 
		{"bankerror", "contest", "fee", "go", "gotojail", "incometax", "inherit",
		 "insurancematures", "jailfreechest", "opera", "payhospital", "repairs", "schooltax",
		 "services", "stock", "xmasfund"};
	
	// number of cards in the deck
	private final int NUM_COMM_CHEST_CARDS = 16;
	
	public CommunityChestDeck ()
	{
		// create the commchestArrayList
		commchestArrayList = new ArrayList<String>();
		
		// initialize the commchestArrayList by populating it with the
		// string names from the commchestArrayList
		for (String x: commchestStringArray)
			commchestArrayList.add(x);
		
		// shuffle the deck
		shuffleDeck();
	} // end CommunityChestDeck constructor
	
	// shuffles the ArrayList
	public void shuffleDeck()
	{
		Collections.shuffle(commchestArrayList);
	} // end shuffleDeck
	
	// returns the number of cards in the deck
	public int getNumCommChestCards()
	{
		return NUM_COMM_CHEST_CARDS;
	} // end getNumCommChestCards
	
	// returns the StringArray
	// (not sure if this is needed)
	public String[] getStringArray()
	{
		return commchestStringArray;
	} // end getStringArray
		
	// copies the StringArray into another String array
	// (not sure if this is needed)
	public void copyStringArray(String[] str)
	{
		for(int i=0; i<NUM_COMM_CHEST_CARDS ; i++)
		{
			str[i] = commchestStringArray[i];
		}
	} // end copyStringArray
	
	// returns the ArrayList
	// (not sure if this is needed)
	public ArrayList<String> getArrayList()
	{
		return commchestArrayList;
	} // end getArrayList
	
	// copies the ArrayList into another ArrayList
	public void copyArrayList(ArrayList<String> list)
	{
		for(int i=0; i<NUM_COMM_CHEST_CARDS ; i++)
		{
			list.add(commchestArrayList.get(i));
		}		
	} // end copyArrayList
	
	// removes first object in the ArrayList and moves
	// it to the end of the list
	public void frontToBack(ArrayList<String> al)
	{
		//System.out.println(commchestArrayList);
		al.add(al.remove(0));
		//System.out.println(commchestArrayList);
	} // end frontToBack
} // end class CommunityChestDeck
